package com.ulez.scaleview;

import android.os.Bundle;
import android.os.SystemClock;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    private ScaleView scaleView;
    private ScaleView scaleView2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        scaleView = (ScaleView) findViewById(R.id.scaleview);
        scaleView2 = (ScaleView) findViewById(R.id.scaleview2);
        scaleView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        for (int i=1;i<361;i++){
                            SystemClock.sleep(10);
                            scaleView.setProgress(i);
                        }
                    }
                }).start();
            }
        });
        scaleView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        for (int i=1;i<361;i++){
                            SystemClock.sleep(10);
                            scaleView2.setProgress(i);
                            if (i==360)
                                scaleView2.setProgress(-100);
                        }
                    }
                }).start();
            }
        });
    }
}
